{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Custom Display Logic" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As described in the [Rich Output](Rich Output.ipynb) tutorial, the IPython display system can display rich representations of objects in the following formats:\n", "\n", "* JavaScript\n", "* HTML\n", "* PNG\n", "* JPEG\n", "* SVG\n", "* LaTeX\n", "* PDF\n", "\n", "This Notebook shows how you can add custom display logic to your own classes, so that they can be displayed using these rich representations. There are two ways of accomplishing this:\n", "\n", "1. Implementing special display methods such as `_repr_html_` when you define your class.\n", "2. Registering a display function for a particular existing class.\n", "\n", "This Notebook describes and illustrates both approaches." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import the IPython display functions." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from IPython.display import (\n", " display, display_html, display_png, display_svg\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Parts of this notebook need the matplotlib inline backend:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Special display methods" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The main idea of the first approach is that you have to implement special display methods when you define your class, one for each representation you want to use. Here is a list of the names of the special methods and the values they must return:\n", "\n", "* `_repr_html_`: return raw HTML as a string\n", "* `_repr_json_`: return a JSONable dict\n", "* `_repr_jpeg_`: return raw JPEG data\n", "* `_repr_png_`: return raw PNG data\n", "* `_repr_svg_`: return raw SVG data as a string\n", "* `_repr_latex_`: return LaTeX commands in a string surrounded by \"$\"." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As an illustration, we build a class that holds data generated by sampling a Gaussian distribution with given mean and standard deviation. Here is the definition of the `Gaussian` class, which has a custom PNG and LaTeX representation." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from IPython.core.pylabtools import print_figure\n", "from IPython.display import Image, SVG, Math\n", "\n", "class Gaussian(object):\n", " \"\"\"A simple object holding data sampled from a Gaussian distribution.\n", " \"\"\"\n", " def __init__(self, mean=0.0, std=1, size=1000):\n", " self.data = np.random.normal(mean, std, size)\n", " self.mean = mean\n", " self.std = std\n", " self.size = size\n", " # For caching plots that may be expensive to compute\n", " self._png_data = None\n", " \n", " def _figure_data(self, format):\n", " fig, ax = plt.subplots()\n", " ax.hist(self.data, bins=50)\n", " ax.set_title(self._repr_latex_())\n", " ax.set_xlim(-10.0,10.0)\n", " data = print_figure(fig, format)\n", " # We MUST close the figure, otherwise IPython's display machinery\n", " # will pick it up and send it as output, resulting in a double display\n", " plt.close(fig)\n", " return data\n", " \n", " def _repr_png_(self):\n", " if self._png_data is None:\n", " self._png_data = self._figure_data('png')\n", " return self._png_data\n", " \n", " def _repr_latex_(self):\n", " return r'$\\mathcal{N}(\\mu=%.2g, \\sigma=%.2g),\\ N=%d$' % (self.mean,\n", " self.std, self.size)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create an instance of the Gaussian distribution and return it to display the default representation:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlEAAAGLCAYAAADnMccKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAGsJJREFUeJzt3X2QndddH/DvsUQs5cXIRoCNA9mGGIR5Dy9KiBMnMmnq\n", "BAbamjOdYIOBafEMGd4MocEGUrAbG1Sgw7sLwWAI5bhT6tC0abCN4rQlSjEhmVAbG1yRRHgTYgsp\n", "xEKOlKd/3LvmeiOvdo/26t6VPp9/ds9znufe32rvaL/znHOeU4ZhCAAAa3PWrAsAANiIhCgAgA5C\n", "FABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAAOghRsIGVUraMv5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TffmuT3k9yS5FiS+5Nc\n", "01obplYhwGlocr+863YtHJx1PcDareZO1N7W2uVLjVrrf0tyRWttsdZ6bZIrk9w2rQIBAObRakLU\n", "F9da70ny8STfnuSx1triuO+2JDdHiAIAzjCrmVj+3NbaS5K8LsmtSR6Z6HskyXlTqAsAYK6dMES1\n", "1h4ff31XkseTfNpE9/Ykj06nNACA+bViiKq17qy1XjH+/vlJ9ifZUmu9YHzKVUnunG6JAADz50Rz\n", "ou5L8sO11tdkdMfpmoyG726vtR5Lcl9rbfeUawQAmDsrhqjW2qEk37Ds8IeTXDK1igAANgBPLAcA\n", "6CBEAQB0sO0LwJRs27p5xx33PrQnSc4/5+x9Oy+68OrZVgSsJyEKYEoOHD665cbx1i7X71qYcTXA\n", "ejOcBwDQQYgCAOggRAEAdBCiAAA6mFgOcApMrtRLkk1nlR0zLAdYB0IUwCkwuVIvSa7btXBwlvUA\n", "J89wHgBAByEKAKCDEAUA0EGIAgDoYGI5wBxbvqrPHnwwP4QogDm2fFWfPfhgfhjOAwDoIEQBAHQQ\n", "ogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDo4InlABvU3gf337p46MjCUtuWMHBqCVEA\n", "G9TioSMLN9gSBmbGcB4AQAchCgCggxAFANBBiAIA6GBiOcAGsm3r5h133PvQniTZdFbZMeNy4Iwm\n", "RAFsIAcOH91y43hF3nW7Fg7Ouh44kxnOAwDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCD\n", "EAUA0EGIAgDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDosHk1J9Van5Pk\n", "niTflOTvktyS5FiS+5Nc01obplYhAMAcOuGdqFrrWUlel+RNSUqS3UmuaK1dmuSBJFdOtUIAgDm0\n", "muG8a5P8SpK/H5//WGttcdx3W5JdU6oNAGBurRiiaq1fnaS01t49cf6jE6c8kuS8KdUGADC3TjQn\n", "aleSr6m1vjDJjiSvSvL+if7teXKoAgA4I6wYolpr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\n", "wDPH7d1JrmitLdZar01yZZLbnuriqQzntdY+0Fr7tiSPZ/RHMUlemuS3x/1Hk/zXJDun8f5seD9Q\n", "a31XrXX3rAth7thyirX64lrrPbXWu2qtz551McyX1to1Sd6XJLXWrUkea60tjrtvS7JrpetP6k5U\n", "rfXzk/zsssMfaq1dfZzTz0vy3on20lYxnIGe6rOT5Dtba78xPufnaq0vX3ouGcSWU6zdc1trj9da\n", "vzrJG5JcNeuCmFvnJnl0ov1ITpBTTipEtdb+PMlqb5M+mmT7RPvTk/zFybw/G9cqPzu/l+TLkwhR\n", "LFn6f+Svx+3teXKogidprT0+/vquWuv2E53PGe1AnhyatufJoeqTnIrVeUtbv9yd5NVJUmv9lCSv\n", "TGJCKE9Sa31trfUzxs2vS3LvLOth7ixtObU0IfS4W05BktRad9Zarxh///z8Q/iGT9JaO5xka631\n", "gvGhq5LcudI1pyJEDUnSWnsgyR/VWv9XknuS/FRrzfbvLPd/kry51vr2JI+21vbMuB7miC2nWKP7\n", "klxVa92T5Pokr5ttOcyxpfnb1ya5ffw36Hmttd9e6SLbvgAAdPCwTQCADkIUAEAHIQoAoIMQBQDQ\n", "QYgCAOggRAEAdBCiAAA6CFEAAB2EKACADv8fn0xUCxJB1sMAAAAASUVORK5CYII=\n" ], "text/latex": [ "$\\mathcal{N}(\\mu=2, \\sigma=1),\\ N=1000$" ], "text/plain": [ "<__main__.Gaussian at 0x10665a4e0>" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = Gaussian(2.0, 1.0)\n", "x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also pass the object to the `display` function to display the default representation:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlEAAAGLCAYAAADnMccKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAGsJJREFUeJzt3X2QndddH/DvsUQs5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derfUlSX43\n", "yZe21j48Pva9Sb4po/D2htbam6f1/mxMtdarM1qo8OHxoe9trb1ndhUxb2w5xVrUWh9NsvR/yFtb\n", "azfPsh7my/gJA29K8vbW2s211ouT3JLkWJL7k1zTWnvKyeNTCVG11s9O8m1J7k5Sxsd2JHlBa+1F\n", "tdbNSe6utb6ttfb306iBDWtI8uOttd+ddSHMn8ktp2qtn5rkzUkuPcFlnNn2ttYun3URzK2bMnrK\n", "wDPH7d1JrmitLdZar01yZZLbnuriqQzntdY+0Fr7tiSPZ/RHMUlemuS3x/1Hk/zXJDun8f5seD9Q\n", "a31XrXX3rAth7thyirX64lrrPbXWu2qtz551McyX1to1Sd6XJLXWrUkea60tjrtvS7JrpetP6k5U\n", "rfXzk/zsssMfaq1dfZzTz0vy3on20lYxnIGe6rOT5Dtba78xPufnaq0vX3ouGcSWU6zdc1trj9da\n", "vzrJG5JcNeuCmFvnJnl0ov1ITpBTTipEtdb+PMlqb5M+mmT7RPvTk/zFybw/G9cqPzu/l+TLkwhR\n", "LFn6f+Svx+3teXKogidprT0+/vquWuv2E53PGe1AnhyatufJoeqTnIrVeUtbv9yd5NVJUmv9lCSv\n", "TGJCKE9Sa31trfUzxs2vS3LvLOth7ixtObU0IfS4W05BktRad9Zarxh///z8Q/iGT9JaO5xka631\n", "gvGhq5LcudI1pyJEDUnSWnsgyR/VWv9XknuS/FRrzfbvLPd/kry51vr2JI+21vbMuB7miC2nWKP7\n", "klxVa92T5Pokr5ttOcyxpfnb1ya5ffw36Hmttd9e6SLbvgAAdPCwTQCADkIUAEAHIQoAoIMQBQDQ\n", "QYgCAOggRAEAdBCiAAA6CFEAAB2EKACADv8fn0xUCxJB1sMAAAAASUVORK5CYII=\n" ], "text/latex": [ "$\\mathcal{N}(\\mu=2, \\sigma=1),\\ N=1000$" ], "text/plain": [ "<__main__.Gaussian at 0x10665a4e0>" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use `display_png` to view the PNG representation:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlEAAAGLCAYAAADnMccKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAGsJJREFUeJzt3X2QndddH/DvsUQs5cXIRoCNA9mGGIR5Dy9KiBMnMmnq\n", "BAbamjOdYIOBafEMGd4MocEGUrAbG1Sgw7sLwWAI5bhT6tC0abCN4rQlSjEhmVAbG1yRRHgTYgsp\n", "xEKOlKd/3LvmeiOvdo/26t6VPp9/ds9znufe32rvaL/znHOeU4ZhCAAAa3PWrAsAANiIhCgAgA5C\n", "FABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAAOghRsIGVUraMv5ZSyq5Z1zMPSinnllK+atZ1AKc/\n", "IQo2oFLKV5ZS3pPkQClla5IfTPIXp+i9P7eUclMp5d+XUv6glPIVp+J9n6KWraWUXy6lvHjp2DAM\n", "B5K8opTyvFnVtRrHq32i77NLKb9SSvmuUsqvllIWTrYPWH9CFMypUsofl1JecZzjm5Jcn+Tnkrwo\n", "yRcleWwYhvefgprOSnJtktcNw/A9SX4zydtKKdun/d7HqeU7k7w+yRVJyrLun0zyE6e6ptU6Qe1J\n", "cluS24Zh+IUkv5rkd9ahD1hnQhTMoXEo+fKM/sgu97IkvzgMw68Ow/AnSb4/ya+fotIuSvI1ST5r\n", "3P6dJM9I8o2n6P2fMAzDrwzD8ENJPnqcvseT3F9KedFaX7eUcnYp5UdKKftLKfeVUspE36tLKfeX\n", "Un6/lPJPp1F7KeXzknzpMAz/c3zuO5N8finlczr7ntNbJ7AyIQrm08VJfiPJPy+lPG1Z38uS/GGS\n", "lFLOS/IpwzB87BTV9XdJnp3kgiQZhuHo+Ni5p+j91+ItSV691ouGYTiS0Z2s25JcmImAOAzDm5L8\n", "xjAMXz8Mw++tV6HLfEmSDyw79sGM7jr29H3NFGoE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DY\n", "CNaaW9yJAgDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAA\n", "OghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAAOghRAAAdhCgAgA6bZ10AwOli\n", "74P7b108dGRhqX3+OWfv23nRhVfPriJgmoQogHWyeOjIwg1377t0qX39roUZVgNMm+E8AIAOQhQA\n", "QAchCgCggxAFANBBiAIA6CBEAQB0EKIAADoIUQAAHYQoAIAOnlgOMGO2i4GNSYgCmDHbxcDGZDgP\n", "AKCDEAUA0EGIAgDoIEQBAHQwsRxgzmzbunnHHfc+tCexUg/mmRAFMGcOHD665cbxaj0r9WB+Gc4D\n", "AOggRAEAdBCiAAA6CFEAAB1MLAeYgcn98jadVXbMuBygwwlDVK310STvGTffmuT3k9yS5FiS+5Nc\n", "01obplYhwGlocr+863YtHJx1PcDareZO1N7W2uVLjVrrf0tyRWttsdZ6bZIrk9w2rQIBAObRakLU\n", "F9da70ny8STfnuSx1triuO+2JDdHiAIAzjCrmVj+3NbaS5K8LsmtSR6Z6HskyXlTqAsAYK6dMES1\n", "1h4ff31XkseTfNpE9/Ykj06nNACA+bViiKq17qy1XjH+/vlJ9ifZUmu9YHzKVUnunG6JAADz50Rz\n", "ou5L8sO11tdkdMfpmoyG726vtR5Lcl9rbfeUawQAmDsrhqjW2qEk37Ds8IeTXDK1igAANgBPLAcA\n", "6CBEAQB0sO0LwJRs27p5xx33PrQnSc4/5+x9Oy+68OrZVgSsJyEKYEoOHD665cbx1i7X71qYcTXA\n", "ejOcBwDQQYgCAOggRAEAdBCiAAA6mFgOcApMrtRLkk1nlR0zLAdYB0IUwCkwuVIvSa7btXBwlvUA\n", "J89wHgBAByEKAKCDEAUA0EGIAgDoYGI5wBxbvqrPHnwwP4QogDm2fFWfPfhgfhjOAwDoIEQBAHQQ\n", "ogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDo4InlABvU3gf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55SR6ZaH9kfOyvTroiYK699LnnPvZZ55z90SR53qc9/WkPHzoy65IAZqIMw7Dmi2qt\n", "NyV5U2vtveP2Lya5qbX2/snz7rrrrrW/OADAjFx22WVltef23om6K8k3J3lvrXVbkouXB6i1FgIA\n", "sJF0zYlqrf1BktRa35HkLUl+cD2LAgCYd13DeQAAZzp75wEAdBCiAAA6CFEAAB2mtnderfUlSX43\n", "yZe21j48Pva9Sb4po/D2htbam6f1/mxMtdarM1qo8OHxoe9trb1ndhUxb2w5xVrUWh9NsvR/yFtb\n", "azfPsh7my/gJA29K8vbW2s211ouT3JLkWJL7k1zTWnvKyeNTCVG11s9O8m1J7k5Sxsd2JHlBa+1F\n", "tdbNSe6utb6ttfb306iBDWtI8uOttd+ddSHMn8ktp2qtn5rkzUkuPcFlnNn2ttYun3URzK2bMnrK\n", "wDPH7d1JrmitLdZar01yZZLbnuriqQzntdY+0Fr7tiSPZ/RHMUlemuS3x/1Hk/zXJDun8f5seD9Q\n", "a31XrXX3rAth7thyirX64lrrPbXWu2qtz551McyX1to1Sd6XJLXWrUkea60tjrtvS7JrpetP6k5U\n", "rfXzk/zsssMfaq1dfZzTz0vy3on20lYxnIGe6rOT5Dtba78xPufnaq0vX3ouGcSWU6zdc1trj9da\n", "vzrJG5JcNeuCmFvnJnl0ov1ITpBTTipEtdb+PMlqb5M+mmT7RPvTk/zFybw/G9cqPzu/l+TLkwhR\n", "LFn6f+Svx+3teXKogidprT0+/vquWuv2E53PGe1AnhyatufJoeqTnIrVeUtbv9yd5NVJUmv9lCSv\n", "TGJCKE9Sa31trfUzxs2vS3LvLOth7ixtObU0IfS4W05BktRad9Zarxh///z8Q/iGT9JaO5xka631\n", "gvGhq5LcudI1pyJEDUnSWnsgyR/VWv9XknuS/FRrzfbvLPd/kry51vr2JI+21vbMuB7miC2nWKP7\n", "klxVa92T5Pokr5ttOcyxpfnb1ya5ffw36Hmttd9e6SLbvgAAdPCwTQCADkIUAEAHIQoAoIMQBQDQ\n", "QYgCAOggRAEAdBCiAAA6CFEAAB2EKACADv8fn0xUCxJB1sMAAAAASUVORK5CYII=\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display_png(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
display
and display_png
. The former computes all representations of the object, and lets the notebook UI decide which to display. The later only computes the PNG representation.\n",
"